/*
 * BonusPoint.java, bonuses -- extra bal, pass ball, or enlarged bat
 */
package bounce;

import java.awt.Color;
import java.awt.Graphics;

/**
 *
 * @author PANAIMIN
 */
public class BonusPoint {

    public enum FUNCTIONS {
        ExtraBall,
        PassBall,
        EnlargedBat
    }

    public static final int RADIUS = 4;
    public static final int DIAMETER = RADIUS * 2;
    public static final int SPEED = 2;

    public BonusPoint(FUNCTIONS f, int x, int y) {
        _function = f;
        _x = x;
        _y = y;
    }

    public void draw(Graphics g) {
        int colorIndex = _function == FUNCTIONS.ExtraBall ? 0 : _function == FUNCTIONS.PassBall ? 1 : 2;
        g.setColor(_colors[colorIndex]);
        g.fillOval(_x - RADIUS, _y - RADIUS, DIAMETER, DIAMETER);
    }

    public void fall() {
        _y += SPEED;
        _stage.repaint(0, _x - RADIUS, _y - RADIUS - SPEED, DIAMETER, DIAMETER + SPEED);
    }

    public int getX() { return _x; }
    public int getY() { return _y; }
    public FUNCTIONS getFunction() { return _function; }

    private FUNCTIONS       _function;
    private static Color[]  _colors = new Color[] {
        Color.PINK,
        Color.CYAN,
        Color.RED
    };
    private Stage           _stage = Stage.Instance();
    private int             _x;
    private int             _y;
}
